home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / GemsII / radiosity / rad.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-16  |  3.5 KB  |  109 lines  |  [TEXT/MPS ]

  1. /*****************************************************************************
  2. *    rad.h
  3. *
  4. *    This is the headerfile which defines the data structures used in rad.c
  5. *
  6. *     Copyright (C) 1990-1991 Apple Computer, Inc.
  7. *     All rights reserved.
  8. *
  9. *    12/1990 S. Eric Chen    
  10. ******************************************************************************/
  11.  
  12. #ifndef __RAD__
  13. #define __RAD__
  14.  
  15. #define kNumberOfRadSamples    3
  16.  
  17. typedef struct { float x, y, z; } TPoint3f;
  18. typedef TPoint3f TVector3f;
  19. typedef struct { unsigned char a, r, g, b;} TColor32b;
  20.  
  21. typedef struct {
  22.     double samples[kNumberOfRadSamples];
  23. } TSpectra;
  24.  
  25. typedef struct {
  26.     TSpectra* reflectance; /* diffuse reflectance of the patch */
  27.     TSpectra* emission;    /* emission of the patch */
  28.     TPoint3f center;    /* center of the patch where hemi-cubes will be placed */
  29.     TVector3f normal;    /* normal of the patch; for orienting the hemi-cube */
  30.     TSpectra unshotRad;    /* unshot radiosity of the patch */
  31.     double area;    /* area of the patch */
  32. } TPatch;
  33.  
  34. typedef struct {
  35.     unsigned short nVerts;    /* number of vertices of the element */
  36.     unsigned long* verts;    /* vertices */
  37.     TVector3f normal;    /* normal of the element; for backface removal */
  38.     TSpectra rad;    /* total radiosity of the element */
  39.     double area;    /* area of the patch */
  40.     TPatch* patch;    /* pointer to the parent patch */
  41. } TElement;
  42.  
  43. typedef struct {
  44.     TPoint3f camera;    /* camera location */
  45.     TPoint3f lookat;    /* point of interest */
  46.     TVector3f up;    /* view up vector */
  47.     float fovx, fovy;    /* field of view in x, y (in degree) */
  48.     float near, far;    /* distance from the camera to the near and far planes */
  49.     unsigned short xRes, yRes;    /* resolution of the frame buffer */
  50.     unsigned long* buffer;    /* pointer to the frame buffer */
  51.     long wid;    /* id or pointer to the window associated with the view */
  52. } TView;    
  53.  
  54. /* Radiosity input parameters */
  55. typedef struct {
  56.     double threshold; /* convergence threshold (fraction of the total emitted                         energy) */
  57.     unsigned long nPatches; /* number of patches */
  58.     TPatch *patches;    /* patches */
  59.     unsigned long nElements; /* number of elements */
  60.     TElement *elements;    /* elements */
  61.     unsigned long nPoints;    /* nubmer of element vertices */
  62.     TPoint3f *points;    /* element vertices */
  63.     TView displayView;    /* view to display the results */
  64.     unsigned short hemicubeRes; /* hemi-cube resolution */
  65.     float worldSize;    /* approximate diameter of the bounding sphere of the world.              used for placing near and far planes in the hemi-cube computation*/
  66.     float intensityScale;    /* used to scale intensity for display */
  67.     int    addAmbient;        /* whether or not to add the ambient approximation in display */
  68. } TRadParams;
  69.  
  70. /* make it C++ friendly */
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif __cplusplus
  74.  
  75. /* initialization */
  76. void InitRad(TRadParams *p);
  77. /* main iterative loop */
  78. void DoRad();
  79. /* final clean up */
  80. void CleanUpRad();
  81.  
  82. /* The following routines should be provided by the user */
  83.  
  84. /* Clear buffer. Set up view transformation.*/
  85. /* Open a window if necessary (check if view->wid is zero) */
  86. void BeginDraw(
  87. TView *view,     /* the viewing parameters and frame buffer to draw to*/
  88. unsigned long color /* color used to clear the buffer */
  89. );
  90.  
  91. /* Draw a 3-d polygon with a constant color */
  92. void DrawPolygon(
  93. int nPts, /* number of points in the polygon */
  94. TPoint3f *pts, /* points of the polygon */
  95. TVector3f* normal, /* normal of the polygon */
  96. unsigned long color /* color to be drawn with */
  97. );
  98.  
  99. /* Finish the drawing of polygons to the frame buffer*/
  100. /* Display the buffer content in the window if necessary */
  101. void EndDraw();
  102.  
  103. #ifdef __cplusplus
  104. };
  105. #endif __cplusplus
  106.  
  107. #endif __RAD__
  108.  
  109.